home *** CD-ROM | disk | FTP | other *** search
- menuArray = new Array();
-
-
- function writeMenus()
- {
- for(var x=0; x<menuArray.length; x++)
- document.write('<style type="text/css">' + menuArray[x].getCSS() + '#dummy {position:absolute; visibility:hidden;}</style><div id="menuDescriptionDiv"></div>' + menuArray[x].getHTML());
-
- document.write('<div id="menuDescriptionDiv"></div>');
- }
-
-
-
- function activateMenus()
- {
- for(var x=0; x<menuArray.length; x++)
- menuArray[x].activate();
- hintObj = new divObject('menuDescriptionDiv', 'document.');
- hintObj.activate();
- }
-
-
- function hideAllMenus(){
- for(var x=0; x<menuArray.length; x++)
- menuArray[x].hide();
- }
- function hideAllSubMenus()
- {
- for(var x=0; x<menuArray.length; x++)
- menuArray[x].hideSubMenus();
- hideAllMenus();
- }
-
-
-
- function menuSys(x, y, cellWidth, cellHeight, menuXOffset, menuYOffset, borderWidth, borderColour, classOff, classOn, bgColourOff, bgColourOn, subMenuRightPic, subMenuDownPic, subMenuRightPicOn, subMenuDownPicOn, direction, rememberHilight)
- {
- //Fix weird IE 5.00 bug where numeric arguments are passes as NaN
- this.id = menuArray.length;
- menuArray[this.id] = this;
-
- this.cellWidth = cellWidth;
- this.cellHeight = cellHeight;
- this.menuXOffset = menuXOffset;
- this.menuYOffset = menuYOffset;
- this.borderWidth = borderWidth;
- this.borderColour = borderColour;
- this.classOff = classOff;
- this.classOn = classOn;
- this.bgColourOff = bgColourOff;
- this.bgColourOn = bgColourOn;
- this.subMenuPic = new Array(new Array(subMenuDownPic, subMenuDownPicOn), new Array(subMenuRightPic, subMenuRightPicOn));
- var preLoadR = new Image();
- preLoadR.src = subMenuRightPicOn;
- var preLoadD = new Image();
- preLoadD.src = subMenuDownPicOn;
- this.direction = direction;
- this.rememberHilight = rememberHilight;
-
- this.left = x;
- this.top = y;
- this.topObj = this;
-
- this.parent = false;
- this.menuWidth = 2*borderWidth + cellWidth;
-
- this.div = new divObject('M' + this.id, 'document.');
-
- this.cells = new Array();
- this.addCell = addCell;
-
- this.activate = menuSysActivate;
- this.getHTML = menuSysGetHTML;
- this.getCSS = menuSysGetCSS;
- this.hideSubMenus = menuSysHideSubMenus;
-
- this.name = 'M' + this.id;
- this.address = 'menuArray[' + this.id + ']';
- this.moveTo = menuSysMoveTo;
-
- this.hide = new Function("this.hideSubMenus(); this.div.hide();");
- this.show = new Function("this.hideSubMenus(); this.div.show();");
- }
-
-
- function menuSysMoveTo(x, y)
- {
- this.left = x;
- this.top = y;
- this.div.moveTo(x, y);
- this.hideSubMenus();
- }
-
-
-
- function menuSysActivate()
- {
- this.div.activate()
- this.div.resizeTo(this.topObj.menuWidth, this.cells.length*(this.topObj.borderWidth+this.topObj.cellHeight) + this.topObj.borderWidth);
- this.div.setBgColour(this.topObj.borderColour);
- for(var x=0; x<this.cells.length; x++)
- {
- this.cells[x].div.activate();
- this.cells[x].div.resizeTo(this.topObj.cellWidth, this.topObj.cellHeight);
- this.cells[x].div.setBgColour(this.topObj.bgColourOff);
- this.cells[x].div.moveTo(this.topObj.borderWidth, x*(this.topObj.borderWidth+this.topObj.cellHeight) + this.topObj.borderWidth);
- this.cells[x].div.show();
-
- this.cells[x].clickDiv.activate();
- this.cells[x].clickDiv.resizeTo(this.topObj.cellWidth, this.topObj.cellHeight);
- this.cells[x].clickDiv.moveTo(this.topObj.borderWidth, x*(this.topObj.borderWidth+this.topObj.cellHeight) + this.topObj.borderWidth);
- this.cells[x].clickDiv.captureEvents('mouseover', this.address + '.cells[' + x + '].mouseover();');
- this.cells[x].clickDiv.captureEvents('mouseout', this.address + '.cells[' + x + '].mouseout();');
- this.cells[x].clickDiv.captureEvents('click', this.address + '.cells[' + x + '].click();');
- this.cells[x].clickDiv.show();
- //IE6 Fix - Watch out for Opera faking being IE
- if((browserVars.type.ie) && (typeof(this.cells[x].clickDiv.div.filter) != 'undefined'))
- {
- this.cells[x].clickDiv.setBgColour('red');
- this.cells[x].clickDiv.div.filter = 'Alpha(Opacity=0)';
- }
-
- this.cells[x].onDiv.activate();
- this.cells[x].onDiv.resizeTo(this.topObj.cellWidth, this.topObj.cellHeight);
- this.cells[x].onDiv.moveTo(this.topObj.borderWidth, x*(this.topObj.borderWidth+this.topObj.cellHeight) + this.topObj.borderWidth);
- this.cells[x].onDiv.setBgColour(this.topObj.bgColourOn);
- this.cells[x].onDiv.hide();
-
- if(this.cells[x].subMenu) this.cells[x].subMenu.activate();
- }
-
- if((!this.parent) && (this.direction == 0))
- {
- for(var x=0; x<this.cells.length; x++)
- {
- this.cells[x].div.moveTo(x*(this.borderWidth+this.cellWidth) + this.borderWidth, this.borderWidth);
- this.cells[x].clickDiv.moveTo(x*(this.borderWidth+this.cellWidth) + this.borderWidth, this.borderWidth);
- this.cells[x].onDiv.moveTo(x*(this.borderWidth+this.cellWidth) + this.borderWidth, this.borderWidth);
- if((this.cells[x].subMenu) && (this.cells[x].showArrow))
- {
- this.cells[x].div.swapImage(this.cells[x].name + 'ArrowOff', this.subMenuPic[0][0]);
- this.cells[x].onDiv.swapImage(this.cells[x].name + 'ArrowOn', this.subMenuPic[0][1]);
- this.cells[x].direction = 0;
- }
- }
- this.div.resizeTo(this.cells.length*(this.borderWidth+this.cellWidth) + this.topObj.borderWidth, this.cellHeight + 2*this.borderWidth);
- }
- if(!this.parent)
- {
- this.div.moveTo(this.left, this.top);
- this.div.show();
- }
- }
-
-
-
-
-
-
-
- function menuSysGetHTML()
- {
- var HTML = '<div id="' + this.name + '">';
-
- for(var x=0; x<this.cells.length; x++)
- {
- HTML += '<div id="' + this.cells[x].name + '" class="' + this.topObj.classOff + '">';
- if((!this.cells[x].subMenu) || (!this.cells[x].showArrow))HTML += this.cells[x].textOff;
- else HTML += '<table border="0" cellspacing="0" cellpadding="0" width="' + this.topObj.cellWidth + '"><tr><td width="100%" class="' + this.topObj.classOff + '">' + this.cells[x].textOff + '</td><td><img src="' + this.topObj.subMenuPic[1][0] + '" name="' + this.cells[x].name + 'ArrowOff"></td></tr></table>';
- HTML += '</div>';
-
- HTML += '<div id="' + this.cells[x].name + 'On" class="' + this.topObj.classOn + '">';
- if((!this.cells[x].subMenu) || (!this.cells[x].showArrow))HTML += this.cells[x].textOn;
- else HTML += '<table border="0" cellspacing="0" cellpadding="0" width="' + this.topObj.cellWidth + '"><tr><td width="100%" class="' + this.topObj.classOn + '">' + this.cells[x].textOn + '</td><td><img src="' + this.topObj.subMenuPic[1][1] + '" name="' + this.cells[x].name + 'ArrowOn".></td></tr></table>';
- HTML += '</div>';
-
- HTML += '<div id="' + this.cells[x].name + 'Click"> </div>';
- }
- HTML += '</div>';
-
- for(var x=0; x<this.cells.length; x++)
- if(this.cells[x].subMenu) HTML += this.cells[x].subMenu.getHTML();
-
- return HTML;
- }
-
-
-
-
-
-
-
- function menuSysGetCSS()
- {
- var CSS = '#' + this.name + ', ';
-
- for(var x=0; x<this.cells.length; x++)
- CSS += '#' + this.cells[x].name + ', #' + this.cells[x].name + 'On , #' + this.cells[x].name + 'Click, ';
-
- for(var x=0; x<this.cells.length; x++)
- if(this.cells[x].subMenu) CSS += this.cells[x].subMenu.getCSS()
-
- return CSS
- }
-
-
-
-
-
- function addCell(text, action, description, subMenuName, showArrow)
- {
- this.cells[this.cells.length] = new cell(text, action, description, this, this.cells.length, subMenuName, showArrow)
- }
-
-
-
-
-
-
-
-
- function cell(text, action, description, parent, id, subMenuName, showArrow)
- {
- this.textOn = parseCode(text, parent.name + "C" + id, 1);
- this.textOff = parseCode(text, parent.name + "C" + id, 0);
-
- this.description = false;
- if(typeof(description) != 'undefined')
- if(description.length != 0) this.description = description;
-
- this.action = false;
- if(typeof(action) != 'undefined')
- if(action.length != 0) this.action = action;
-
- this.parent = parent;
- this.id = id;
-
- this.direction = 1;
- this.name = this.parent.name + 'C' + this.id
- this.div = new divObject(this.name, this.parent.div.divName + '.document.');
- this.onDiv = new divObject(this.name + 'On', this.parent.div.divName + '.document.');
- this.clickDiv = new divObject(this.name + 'Click', this.parent.div.divName + '.document.');
- this.mouseover = cellMouseover;
- this.mouseout = cellMouseout;
- this.click = cellClick;
-
- if(typeof(subMenuName) != 'undefined')
- {
- this.subMenu = new subMenu(this.parent, this.id);
- this.parent[subMenuName] = this.subMenu;
- this.subMenu.address = this.parent.address + '.' + subMenuName;
- }
- else this.subMenu = false;
-
- if(typeof(showArrow) == 'undefined') showArrow = true;
- this.showArrow = showArrow;
-
- this.showHint = showHint;
- this.hilight = cellHilight;
- this.unHilight = cellUnHilight;
- }
-
- function cellHilight()
- {
- this.onDiv.show();
- this.div.hide();
- }
-
-
- function cellUnHilight()
- {
- this.div.show();
- this.onDiv.hide();
- }
-
- function cellMouseover()
- {
- this.parent.hideSubMenus();
- this.hilight();
- if(this.subMenu) this.subMenu.show();
- if(this.description) this.showHint();
- }
-
-
- function cellMouseout()
- {
- hintObj.hide();
- if((!this.subMenu) || (!this.parent.topObj.rememberHilight)) this.unHilight();
-
- }
-
-
- function cellClick()
- {
- if(this.action) eval(this.action);
- }
-
-
-
- function subMenu(parent, id)
- {
- this.parent = parent;
- this.topObj = this.parent.topObj;
- this.id = id;
- this.address = '';
-
- this.div = new divObject(this.parent.name + 'M' + this.id, 'document.');
-
- this.cells = new Array();
- this.addCell = addCell;
-
- this.activate = menuSysActivate;
- this.getHTML = menuSysGetHTML;
- this.getCSS = menuSysGetCSS;
- this.hideSubMenus = menuSysHideSubMenus;
- this.show = showSubMenu;
- this.shown = false;
-
- this.name = this.parent.name + 'M' + this.id;
- }
-
-
-
- function menuSysHideSubMenus()
- {
- for(var x=0; x<this.cells.length; x++)
- if(this.cells[x].subMenu)
- {
- this.cells[x].subMenu.shown = false;
- this.cells[x].unHilight();
- this.cells[x].subMenu.hideSubMenus();
- this.cells[x].subMenu.div.hide();
- }
- }
-
-
-
- function showSubMenu()
- {
- var subMenu = this;
- var topOffset = 0;
- var leftOffset = 0;
-
- if(this.topObj.direction)
- {
- while(subMenu.parent)
- {
- topOffset += subMenu.id*(this.topObj.cellHeight + this.topObj.borderWidth) + this.topObj.menuYOffset;
- leftOffset += this.topObj.menuWidth + this.topObj.menuXOffset - this.topObj.borderWidth;
- subMenu = subMenu.parent;
- }
- }
- else
- {
- while(subMenu.parent.parent)
- {
- topOffset += subMenu.id*(this.topObj.cellHeight + this.topObj.borderWidth) + this.topObj.menuYOffset;
- leftOffset += this.topObj.menuWidth + this.topObj.menuXOffset - this.topObj.borderWidth;
- subMenu = subMenu.parent;
- }
-
- topOffset += this.topObj.cellHeight + this.topObj.borderWidth;
- leftOffset += subMenu.id*(this.topObj.cellWidth + this.topObj.borderWidth)
- }
-
- topOffset += this.topObj.top;
- leftOffset += this.topObj.left;
-
- this.shown = true;
- this.div.moveTo(leftOffset, topOffset);
- this.div.show();
- }
-
-
-
-
- function showHint()
- {
- var subMenu = this.parent;
- var topOffset = 0;
- var leftOffset = 0;
- var cellAndBorderWidth = subMenu.topObj.cellWidth + subMenu.topObj.borderWidth;
- var cellAndBorderHeight = subMenu.topObj.cellHeight + subMenu.topObj.borderWidth;
-
- if(subMenu.topObj.direction)
- {
- while(subMenu.parent)
- {
- topOffset += subMenu.id * cellAndBorderHeight + subMenu.topObj.menuYOffset;
- leftOffset += subMenu.topObj.menuWidth + subMenu.topObj.menuXOffset - subMenu.topObj.borderWidth;
- subMenu = subMenu.parent;
- }
- topOffset += this.id * cellAndBorderHeight;
- }
- else
- {
- while(subMenu.parent.parent)
- {
- topOffset += subMenu.id * cellAndBorderHeight + subMenu.topObj.menuYOffset;
- leftOffset += subMenu.topObj.menuWidth + subMenu.topObj.menuXOffset - subMenu.topObj.borderWidth;
- subMenu = subMenu.parent;
- }
-
- if(!this.parent.parent)
- {
- leftOffset += this.id * cellAndBorderWidth;
- }
- else
- {
- topOffset += (this.id+1) * cellAndBorderHeight;
- leftOffset += subMenu.id * cellAndBorderWidth;
- }
- }
- topOffset += subMenu.topObj.top;
- leftOffset += subMenu.topObj.left + subMenu.topObj.menuWidth;
-
-
- hintObj.write('<span class="menuDescriptionText">' + this.description + '</span>');
- hintObj.moveTo(leftOffset, topOffset);
- hintObj.show();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function parseCode(text, name, on)
- {
- var numImages = text.substrCount("[MOUSEOVER]");
- if(numImages == 0) return text;
-
- var imageArray = new Array();
- for(x=0; x<numImages; x++)
- {
- imageArray[x] = (text.substring(text.indexOf('[MOUSEOVER]') + 11, text.indexOf('[/MOUSEOVER]'))).split(' ');
- text = text.substring(0, text.indexOf('[MOUSEOVER]')) + '<img src="' + imageArray[x][on] + '">' + text.substr(text.indexOf('[/MOUSEOVER]') + 12);
- }
-
- return text;
- }
-
-
- function strReplace(needle, str)
- {
- var myStr = this.toString();
- var tempArray = myStr.split(needle);
- var newStr = '';
-
- for(var x=0; x<tempArray.length; x++)
- {
- newStr += tempArray[x];
- if(x != tempArray.length-1) newStr += str;
- }
-
- return newStr;
- }
-
-
- function substrCount(needle)
- {
- var myStr = this.toString();
- var count = 0;
- for(var x=0; x<myStr.length; x++)
- if(myStr.indexOf(needle, x) == x) count++;
-
- return count;
- }
-
- String.prototype.strReplace = strReplace;
- String.prototype.substrCount = substrCount;